package com.party.core.service.partner.impl;

import com.google.common.base.Strings;
import com.party.common.paging.Page;
import com.party.core.dao.read.partner.PartnerLabelReadDao;
import com.party.core.dao.write.partner.PartnerLabelWriteDao;
import com.party.core.model.BaseModel;
import com.party.core.model.partner.PartnerLabel;
import com.party.core.model.partner.PartnerRealUserOutput;
import com.party.core.service.partner.IPartnerLabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @program: party-temp
 * @description: 标签接口实现
 * @author: Huaqunhao
 * @create: 2018-08-21 17:56
 **/
@Service
@Transactional
public class PartnerLabelService implements IPartnerLabelService {
    @Autowired
    private PartnerLabelWriteDao partnerLabelWriteDao;
    @Autowired
    private PartnerLabelReadDao partnerLabelReadDao;

    @Override
    public String insert(PartnerLabel partnerLabel) {
        BaseModel.preInsert(partnerLabel);
        boolean result = partnerLabelWriteDao.insert(partnerLabel);
        if (result){
            return partnerLabel.getId();
        }
        return null;
    }

    @Override
    public boolean update(PartnerLabel partnerLabel) {
        partnerLabel.setUpdateDate(new Date());
        return partnerLabelWriteDao.update(partnerLabel);
    }

    @Override
    public boolean deleteLogic(String id) {
        return false;
    }

    @Override
    public boolean delete(String id) {
        if (Strings.isNullOrEmpty(id)){
            return false;
        }
        return partnerLabelWriteDao.delete(id);
    }

    @Override
    public boolean batchDeleteLogic(Set<String> ids) {
        return false;
    }

    @Override
    public boolean batchDelete(Set<String> ids) {
        return false;
    }

    @Override
    public PartnerLabel get(String id) {
        return partnerLabelReadDao.get(id);
    }

    @Override
    public List<PartnerLabel> listPage(PartnerLabel partnerLabel, Page page) {
        return null;
    }

    @Override
    public List<PartnerLabel> list(PartnerLabel partnerLabel) {
        return null;
    }

    @Override
    public List<PartnerLabel> batchList(Set<String> ids, PartnerLabel partnerLabel, Page page) {
        return null;
    }

    @Override
    public List<PartnerLabel> getLabels(String organizationId,List<String> orgIds, Integer isMember) {
        return partnerLabelReadDao.getLabels(organizationId,orgIds,isMember);
    }

    @Override
    public List<Map<String, String>> getLabelMembers(String organizationId, String labelId) {
        return partnerLabelReadDao.getLabelMembers(organizationId,labelId);
    }

    @Override
    public int getRealUserCount(String organizationId,List<String> orgIds,Integer partnerType) {
        return partnerLabelReadDao.getRealUserCount(organizationId,orgIds,partnerType);
    }

    @Override
    public int getMemberUserCount(String organizationId,List<String> orgIds, Integer partnerType) {
        return partnerLabelReadDao.getMemberUserCount(organizationId,orgIds,partnerType);
    }

    @Override
    public List<PartnerRealUserOutput> getRealMemberPagelist(String organizationId,List<String> orgIds,
                                                             Integer partnerType,Page page) {
        return partnerLabelReadDao.getRealMemberPagelist(organizationId,orgIds,partnerType,page);
    }

    @Override
    public List<PartnerRealUserOutput> getRealTotalPagelist(String organizationId, String labId, String keyword,
                                                            List<String> orgIds,Integer partnerType, Page page) {
        return partnerLabelReadDao.getRealTotalPagelist(organizationId,labId,keyword,orgIds,partnerType,page);
    }

    @Override
    public List<PartnerRealUserOutput> getRealUserPagelist(String organizationId, String keyword,List<String> orgIds, Page page) {
        return partnerLabelReadDao.getRealUserPagelist(organizationId,keyword,orgIds,page);
    }

    @Override
    public List<PartnerLabel> findByPartnerLabel(PartnerLabel partnerLabel) {
        return partnerLabelReadDao.findByPartnerLabel(partnerLabel);
    }
}
